package com.sto.stoapp.http;

/**
 * 基本消息信息
 * 
 * @author mgf
 * 
 */
public class BaseMessage {
    
    public static final String IS_LOCAL_LOGIN = "is_local_login";
    
    public static final String ROLE_MENU = "roleMenu";

	public static final int REQUEST_FAILURE_ERROR = -1;

	public static final int USER_NUMBER_LENGTH = 4;

	public static final int MAX_PWD_LENGTH = 6;

	public static final String REQUEST_SUCCESS = "000";

	public static final String REQUEST_FAILURE = "0";

	public static final String SALES_VERSION = "B";

	public static final String SCANNER_VERSION = "S";

	public static final String CENTER_VERSION = "C";
	public static final String AVIATION_A_VERSION = "A";
	
	public static final String AVIATION_Y_VERSION = "Y";
	public static final String AVIATION_T_VERSION = "T";
	

	public static final String ADMIN_VERSION = "M";
	
	public static final String SEPARATOR = "|";

	public static final String COMMA = ",";
	
	public static final String DASH = "-";
	public static final String SPILTE = "\\";

	public static final String FORMAT = "gbk";

	public static final String LINE_FEED = "\n";
	
	public static final String DOWNLOAD_SMS_FIELD = "SiteInfo";
	
	public static final String UPLOAD_SMS_FIELD = "BqSms";
	
	public static final String APK_USER_NAME = "STO-";

	// 消息体长度
	protected int messageLength;

	// 消息类型
	protected int messageType;

	public int getMessageLength() {
		return messageLength;
	}

	public void setMessageLength(int messageLength) {
		this.messageLength = messageLength;
	}

	public int getMessageType() {
		return messageType;
	}

	public void setMessageType(int messageType) {
		this.messageType = messageType;
	}

	public String plusString(String s, int length) {
		int primaryLength = s.getBytes().length;
		if (primaryLength >= length) {
			return s.substring(0, length);
		}
		int left = length - primaryLength;
		StringBuilder sb = new StringBuilder();
		sb.append(s);
		for (int i = 0; i < left; i++) {
			sb.append(" ");
		}
		return sb.toString();
	}

	public int isNumeric(String str) {
		int length = str.length();
		for (int i = 0; i < length; i++) {
			if (!Character.isDigit(str.charAt(i))) {
				return i;
			}
		}
		return length;
	}

	public int isNotNumber(String str) {
		int length = str.length();
		for (int i = 0; i < length; i++) {
			if (Character.isDigit(str.charAt(i))) {
				return i;
			}
		}
		return length;
	}

}
